home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Allaire Co189994302001.psc / Module1.bas < prev    next >
Encoding:
BASIC Source File  |  2001-03-29  |  3.8 KB  |  124 lines

  1. Attribute VB_Name = "Module1"
  2. Option Explicit
  3. Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  4. Public Const EM_UNDO = &HC7
  5.  
  6. 'API Constants
  7. Public Const HWND_TOPMOST = -1
  8. Public Const HWND_NOTOPMOST = -2
  9. Public Const SWP_NOMOVE = &H2
  10. Public Const SWP_NOSIZE = &H1
  11. Public Const LB_ITEMFROMPOINT = &H1A9
  12.  
  13. Public Const WM_NCLBUTTONDOWN = &HA1
  14. Public Const HTCAPTION = 2
  15.  
  16. Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
  17.  
  18.  
  19. Public Declare Function CreateProcess Lib "kernel32" _
  20.    Alias "CreateProcessA" _
  21.   (ByVal lpAppName As String, _
  22.    ByVal lpCommandLine As String, _
  23.    ByVal lpProcessAttributes As Long, _
  24.    ByVal lpThreadAttributes As Long, _
  25.    ByVal bInheritHandles As Long, _
  26.    ByVal dwCreationFlags As Long, _
  27.    ByVal lpEnvironment As Long, _
  28.    ByVal lpCurrentDirectory As Long, _
  29.    lpStartupInfo As STARTUPINFO, _
  30.    lpProcessInformation As PROCESS_INFORMATION) As Long
  31.      
  32. Public Declare Function CloseHandle Lib "kernel32" _
  33.   (ByVal hObject As Long) As Long
  34.  
  35. Public Declare Function FindExecutable Lib "shell32.dll" _
  36.    Alias "FindExecutableA" _
  37.   (ByVal lpFile As String, _
  38.    ByVal lpDirectory As String, _
  39.    ByVal sResult As String) As Long
  40.  
  41. Public Declare Function GetTempPath Lib "kernel32" _
  42.    Alias "GetTempPathA" _
  43.   (ByVal nSize As Long, _
  44.    ByVal lpBuffer As String) As Long
  45.    Public Const CREATE_NEW_CONSOLE As Long = &H10
  46. Public Const NORMAL_PRIORITY_CLASS As Long = &H20
  47. Public Const INFINITE As Long = -1
  48. Public Const STARTF_USESHOWWINDOW As Long = &H1
  49. Public Const SW_SHOWNORMAL As Long = 1
  50.  
  51. 'Public Const MAX_PATH As Long = 260
  52. Public Const ERROR_FILE_NO_ASSOCIATION As Long = 31
  53. Public Const ERROR_FILE_NOT_FOUND As Long = 2
  54. Public Const ERROR_PATH_NOT_FOUND As Long = 3
  55. Public Const ERROR_FILE_SUCCESS As Long = 32 'my constant
  56. Public Const ERROR_BAD_FORMAT As Long = 11
  57.  
  58. Public Type STARTUPINFO
  59.   cb As Long
  60.   lpReserved As String
  61.   lpDesktop As String
  62.   lpTitle As String
  63.   dwX As Long
  64.   dwY As Long
  65.   dwXSize As Long
  66.   dwYSize As Long
  67.   dwXCountChars As Long
  68.   dwYCountChars As Long
  69.   dwFillAttribute As Long
  70.   dwFlags As Long
  71.   wShowWindow As Integer
  72.   cbReserved2 As Integer
  73.   lpReserved2 As Long
  74.   hStdInput As Long
  75.   hStdOutput As Long
  76.   hStdError As Long
  77. End Type
  78.  
  79. Public Type PROCESS_INFORMATION
  80.   hProcess As Long
  81.   hThread As Long
  82.   dwProcessId As Long
  83.   dwThreadID As Long
  84. End Type
  85.  
  86. Public Declare Function GetCaretPos Lib "user32" (lpPoint As POINTAPI) _
  87. As Long
  88. Public A As POINTAPI
  89. Public Type POINTAPI
  90. X As Long
  91. Y As Long
  92. End Type
  93.  
  94. Public Function SetWinPos(iPos As Integer, lHWnd As Long) As Boolean
  95.     Dim lWinPos As Long 'A variable to hold the
  96.                         'the value of API window
  97.                         'position constant
  98.     Dim l As Long
  99.     
  100.     'Use a SELECT CASE to set the value of the of
  101.     'the API Window constant
  102.     
  103.     Select Case iPos
  104.         'The window is to set to it regular position
  105.         Case 0
  106.             lWinPos = HWND_NOTOPMOST
  107.         'Set the window always on top
  108.         Case 1
  109.             lWinPos = HWND_TOPMOST
  110.         'You have a bad value, leave the function
  111.         Case Else
  112.             Exit Function
  113.     End Select
  114.     
  115.     'Run the API SetWindowPos function
  116.     If SetWindowPos(lHWnd, lWinPos, 0, 0, 0, 0, SWP_NOMOVE _
  117.                                     + SWP_NOSIZE) Then
  118.         'If the function is greater than 0 (FALSE) then
  119.         'the operation was successful. Return a True for
  120.         'to indicate such.
  121.         SetWinPos = True
  122.     End If
  123. End Function
  124.